from datetime import datetime

from django.db import models

from django.utils import timezone


# Create your models here.
class Counters(models.Model):
    id = models.AutoField
    count = models.IntegerField(max_length=11, default=0)
    createdAt = models.DateTimeField(default=timezone.now())
    updatedAt = models.DateTimeField(default=timezone.now())

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'Counters'  # 数据库表名
        
class ChargePoint(models.Model):
    STATUS_CHOICES = [
        ('AVAILABLE','Available'),
        ('CHARGING','Charging'),
        ('MAINTENANCE','Maintenance'),
    ]
    
    name = models.CharField(max_length=200)
    address = models.CharField(max_length=200)
    status = models.CharField(max_length=20,choices=STATUS_CHOICES,default='AVAILABLE')

class ChargingSession(models.Model):
    charge_point = models.ForeignKey(ChargePoint,on_delete=models.CASCADE)
    start_time = models.DateTimeField(default=timezone.now)
    end_time   = models.DateTimeField(null=True,blank=True)
    total_energy_delivered = models.FloatField(null=True,blank=True)
